jQuery(document).ready(function() {
    jQuery('#fileupload').fileupload({
        dataType: 'json',
        progressall: function(e, data) {
            var progress = parseInt(data.loaded / data.total * 100, 10);
            jQuery('#progress-upload').fadeIn();
            jQuery('#progress-upload .bar .bluebar').css(
                    'width',
                    progress + '%'
                    );
        },
        done: function(e, data) {
            jQuery.each(data.result.files, function(index, file) {
                if (file.url) {
                    jQuery('#avatar').val(file.url);
                    jQuery('#img-avatar').attr('src', file.url);
                }
            });
            jQuery('#progress-upload').fadeOut();
        }
    });
});

